keyvaluestorage-interface
Isomorphic Key-Value Storage Interface
Example
import KeyValueStorage from "keyvaluestorage-interface";
const options = {
asyncStorage: AsyncStorage
database: 'foobar.db'
tableName: 'keyvaluestorage-interface'
}
const storage = new KeyValueStorage(options)
await storage.setItem('user1', { name: 'John Doe', age: 21 })
const item = await storage.getItem('user1')
await storage.removeItem('user1')
API
export class IKeyValueStorage {
public getKeys(): Promise<string[]>;
public getEntries<T = any>(): Promise<[string, T][]>;
public getItem<T = any>(key: string): Promise<T | undefined>;
public setItem<T = any>(key: string, value: T): Promise<void>;
public removeItem(key: string): Promise<void>;
}